<?php
class Paging02
{
    var $total_rows	= 0;
    var $curent		= 0;
    var $perpage	= 10;
    var $url		= "";
//stype
    var $bgcolor	= "#FFFFFF";
    var $color		= '#4D4D4D';
    var $hover		= '#BBBBBB';

// --------------------------------------------------------------------

    /**
     * Generate the pagination links
     *
     * @access	public
     * @return	string
     */
    function show()
    {
        if($this->total_rows == 0) return "";
//
        $page_all	= ceil($this->total_rows/$this->perpage);
//
        if($page_all <=1) return "";
        $this->curent	= empty($this->curent)?1:intval($this->curent);
//
        $linkfirst	= $this->url."&page=1";
        $linklast	= $this->url."&page=".$page_all;
        /*
        * edit ucs.phan
        */
        $page_show=10;
        $page_begin=1;
        $page_begin= intval($this->curent/$page_show);
        $page_count=$page_begin*$page_show+$page_show-1;
        if($page_count>$page_all)
        {
            $page_count=$page_all;
        }
        /*
        * end
        */
        $str	= "";
        $str .="
<script>
    function go_page(event)
    {
        var keypressed = event.keyCode || event.which;
        if (keypressed == 13)
        {
            window.location='".$this->url."&page='+window.document.getElementById('page_go').value;
        }
    }
</script>";

        $str .="<input style='width: 50px; text-align: center;' onkeydown='go_page(event)' type='text' id='page_go' value='".$this->curent."'/> / <input style='width: 50px; text-align: center;' readonly='readonly' type='text' id='page_go' value='".$page_all."'/> <br>";
        $str	.= '<style> .paging {background-color:'.$this->bgcolor.'; text-decoration:none; color:'.$this->color.'; font-weight:bold;}.paging:hover {color:'.$this->hover.';} </style>';
        $str	.= '<a href="'.$linkfirst.'" class="paging">&nbsp;&lt;&lt;&nbsp;</a> ';
        if($page_count>$page_show)
        {
            $link	= $this->url."&page=".($page_begin*$page_show-1);
            $str	.= '<a href="'.$link.'" class="paging">&nbsp;...&nbsp;</a> ';
        }
        for($i=$page_begin*$page_show; $i<=$page_count; $i++)
        {
            if($i!=0)
            {
                $link	= $this->url."&page=".($i);
                if(($i) == $this->curent)
                {
                    $str	.= '<a href="'.$link.'" class="paging" style="color:'.$this->hover.'">&nbsp;'.$i.'&nbsp;</a> ';
                }else
                    $str	.= '<a href="'.$link.'" class="paging">&nbsp;'.$i.'&nbsp;</a> ';
            }
        }
        if($page_count<$page_all)
        {
            $link	= $this->url."&page=".($page_count+1);
            $str	.= '<a href="'.$link.'" class="paging">&nbsp;...&nbsp;</a> ';
        }
        $str	.= '<a href="'.$linklast.'" class="paging">&nbsp;&gt;&gt;&nbsp;</a> <br>';

        $this->curent	= ($this->curent-1)*$this->perpage;
        return $str;
    }
}
?>
<style>
    .menu
    {
        margin-left: -30px;
        margin-top: 1px;
    }
    a{
        text-decoration: none;
        color: white;
        font-weight: bold;
    }
    .menu li
    {
        list-style: none;
        margin-left: 10px;
        float: left;
        background: #373737;
        border: white 1px solid;
        padding: 5 5 5 5;
    }
    .menu  li:hover ,a:hover
    {
        background-color: #7d7d7d;
    }
    .table{
        margin-top: 20px;
        margin-left: auto;
        margin-right: auto;
    }
    .table th{
        background-color: #6495ed;
        padding: 5 5 5 5;
    }
    .table td{
        background-color: #696969;
        text-align: center;
        color: white;
        padding: 5 5 5 5;
    }
</style>
<div style="background-color: #373737; height: 34px; ">
    <ul class="menu">
        <li><a href="GeneralCode.php?action=config_database.php">Config Database</a></li>
        <li><a href="GeneralCode.php?action=general_code.php">General Code</a></li>
    </ul>
</div>

<?php
define('ROOT_PATH', realpath(dirname(__FILE__)));
$file="config_database.php";
if(isset($_GET["action"]))
{
    $file=$_GET["action"];
}
require_once("GeneralCode/".$file);
?>